/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef SX_FLOAT_H
#define SX_FLOAT_H

#include <ostream>

namespace Sx {

/*
 * The Float class provides a set of utility functions that are commonly
 * useful in the context of a complete library. This class provides a localized
 * library of conversion and parsing functions for basic floating point types.
 */
class Float {
public:
	Float();
	Float(const Float& f);

	/* Value Constructors */
	Float(float value);
	Float(double value);
	Float(short value);
	Float(int value);
	Float(long value);

	~Float();

	/*
	 * Sets the value of this float to the provided value.
	 */
	void set(float value);

	/*
	 * Returns the internal float value stored in this Integer.
	 */
	float data() const;

	/*
	 * Allows the interal representation of this Float to be used as a native
	 * float value.
	 */
	operator float () const;

	/*
	 * Returns the maximum possible float value.
	 */
	static Float Max();

	/*
	 * Returns the minimum possible float value.
	 */
	static Float Min();

	/*
	 * Returns the symbolic value of infinity for a Float.
	 */
	static Float Infinity();

	/* 
	 * Returns the squre root of this float value.
	 */
	static float RealSquareRoot(const Float& f);

	/* Returns an unsigned long conversion of this float. */
	static unsigned long ToUnsignedLong(const Float& f);

	/* Operator Defintions */
	Float operator + (const Float& f);
	Float operator + (float f);
	Float operator - (const Float& f);
	Float operator - (float f);
	Float operator * (const Float& f);
	Float operator * (float f);
	Float operator / (const Float& f);
	Float operator / (float f);
	void operator += (const Float& f);
	void operator += (float f);
	void operator -= (const Float& f);
	void operator -= (float f);
	void operator *= (const Float& f);
	void operator *= (float f);
	void operator /= (const Float& f);
	void operator /= (float f);
	void operator = (const Float& f);
	void operator = (float f);

	bool operator == (const Float& f);
	bool operator != (const Float& f);
	bool operator == (float f);
	bool operator != (float f);
	bool operator <= (const Float & f);
	bool operator <= (float f);
	bool operator >= (const Float & f);
	bool operator >= (float f);
	bool operator < (const Float & f);
	bool operator < (float f);
	bool operator > (const Float & f);
	bool operator > (float f);

	/* Global float addition operator */
	friend Float operator + (float v, const Float& f);
	friend Float operator - (float v, const Float& f);
	friend Float operator * (float v, const Float& f);
	friend Float operator / (float v, const Float& f);

	/* Provides basic stream ouput for the value of this Float. */
	friend std::ostream& operator << (std::ostream& out, const Float& f);

protected:
	float value;
};

}

#endif
